using System;
using System.ComponentModel;
using System.Transactions;

using SIS.ENT;
using SIS.DAL;


namespace SIS.BLL {

/// <summary>
/// The TimeScheduleTableManager class is responsible for managing BO.TimeScheduleTable objects in the system.
/// </summary>
[DataObjectAttribute()]
public class TimeScheduleTableManager
  {

#region "Public Methods"

/// <summary>
/// Gets a list with all TimeScheduleTable objects in the database.
/// </summary>
/// <returns>A list with all TimeScheduleTable from the database when the database contains any, or null otherwise.</returns>
[DataObjectMethod(DataObjectMethodType.Select, true)]
public static TimeScheduleTableList GetList(){
return TimeScheduleTableDB.GetList();
}

/// <summary>
/// Gets a single TimeScheduleTable from the database without its data.
/// </summary>
/// <param name="timeTableKey">The TimeTableKey of the TimeScheduleTable in the database.</param>
/// <returns>A TimeScheduleTable object when the TimeTableKey exists in the database, or <see langword="null"/> otherwise.</returns>
[DataObjectMethod(DataObjectMethodType.Select, false)]
public static TimeScheduleTable GetItem(int timeTableKey){
return GetItem(timeTableKey, false);
}

/// <summary>
/// Gets a single TimeScheduleTable from the database.
/// </summary>
/// <param name="timeTableKey">The TimeTableKey of the TimeScheduleTable in the database.</param>
/// <param name="getTimeScheduleTableRecords">Determines whether to load all associated TimeScheduleTable records as well.</param>
/// <returns>
/// A TimeScheduleTable object when the TimeTableKey exists in the database, or <see langword="null"/> otherwise.
/// </returns>
[DataObjectMethod(DataObjectMethodType.Select, false)]
public static TimeScheduleTable GetItem(int timeTableKey, bool getTimeScheduleTableRecords){
TimeScheduleTable myTimeScheduleTable = TimeScheduleTableDB.GetItem(timeTableKey);
return myTimeScheduleTable;
}

/// <summary>
/// Saves a TimeScheduleTable in the database.
/// </summary>
/// <param name="myTimeScheduleTable">The TimeScheduleTable instance to save.</param>
/// <returns>The new TimeTableKey if the TimeScheduleTable is new in the database or the existing TimeTableKey when an item was updated.</returns>
[DataObjectMethod(DataObjectMethodType.Update, true)]
public static int Save(TimeScheduleTable myTimeScheduleTable){
using (TransactionScope myTransactionScope = new TransactionScope()){
int timeScheduleTableTimeTableKey = TimeScheduleTableDB.Save(myTimeScheduleTable);

//  Assign the TimeScheduleTable its new (or existing TimeTableKey).
myTimeScheduleTable.TimeTableKey = timeScheduleTableTimeTableKey;

myTransactionScope.Complete();

return timeScheduleTableTimeTableKey;
}
}

/// <summary>
/// Deletes a TimeScheduleTable from the database.
/// </summary>
/// <param name="myTimeScheduleTable">The TimeScheduleTable instance to delete.</param>
/// <returns>Returns true when the object was deleted successfully, or false otherwise.</returns>
[DataObjectMethod(DataObjectMethodType.Delete, true)]
public static bool Delete(TimeScheduleTable myTimeScheduleTable){
return TimeScheduleTableDB.Delete(myTimeScheduleTable.TimeTableKey);
}

#endregion

}

}
